<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>意达设计</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/dealer.css"/>
</head>
<body class="body">

<!-- header -->
<div class="pageheader"><a href="javascript:void(0);" onclick="api.closeWin();" class="return"></a><span>忘记密码</span></div>

<!-- contact -->
<div class="pad">
    <div class="forpw"><input type="text" placeholder="请输入原手机号" name="phone"></div>
    <div class="forpw"><input type="text" placeholder="请输入验证码" name="yzm">
        <a href="#" onclick="getyzm()">
            <img src="http://192.168.0.119:802/Admin/Public/verify?aa=1" id="yzm" style="height:33px;">
        </a>
    </div>
    <div class="fortxt"><input type="text" placeholder="请输入密码(6-16位数字和字母)" name='password'></div>
    <div class="logBnt"><input type="button" value="确认新密码" onclick="forget()"></div>
</div>



</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../script/adaptive.js"></script>
<script type="text/javascript" src="../script/tabs.js"></script>
<script type="text/javascript">
    window['adaptive'].desinWidth = 750;
    window['adaptive'].baseFont = 28;
    window['adaptive'].maxWidth = 750;
    window['adaptive'].init();
    apiready = function () {
        $api.fixStatusBar($api.dom('.header'));
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){
            api.closeWidget();
        });
        api.showProgress();

    };
    
    function getyzm(){
        $('#yzm').attr('src',webSiteUrl+'/Admin/Public/verify?'+Math.floor(Math.random()*10));
        
    }
    function forget() {
        var phone=$("input[name=phone]").val();
        var password=$("input[name=password]").val();
        var yzm=$("input[name=yzm]").val();
        if(phone==''){
            api.alert({msg:"请输入手机号！"});return;
        }else if( !/^1[34578]\d{9}$/.test(phone)){
            api.alert({msg:"手机号格式错误！"});return;
        }
        if(password==''){
            api.alert({msg:"请输入密码！"});return;
        }else if(!/^[a-zA-Z\d_]{6,16}$/.test(password)){
            api.alert({msg:"密码不合法！"});return;
        }
        if(yzm==''){
            api.alert({msg:"请输入验证码！"});return;
        }

        p={phone:phone,yzm:yzm,password:password};
        api.ajax({
            url: webSiteUrl+'/app/public/forget',
            method: 'post',
            data: {
                values:p,
            }
        }, function(ret, err) {
            api.hideProgress();
            //alert(JSON.stringify(ret));return;

            if(ret.code==200){

                alert(ret.msg);
                api.openWin({
                    name: 'slideName',
                    url: './login.html',
                    pageParam: {
                        
                    }
                });
            }else{
                alert(ret.msg)
            }

        });
    }
</script>

</html>
